package com.ruoyi.system.mapper.bm;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.system.domain.bm.BMCoach;
import com.ruoyi.system.domain.bm.BMPlayer;
import com.ruoyi.system.domain.bm.dto.CoachOrPlayerListDTO;
import com.ruoyi.system.domain.bm.dto.CoachOrPlayerListReturnDTO;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Objects;


/**
 */
public interface BMPlayerMapper extends BaseMapper<BMPlayer>{

    /**
     * 根据用户id 获取参加比赛
     * @param userid
     * @return
     */
    default List<BMPlayer> selectByUserId(Long userid){
        LambdaQueryWrapper<BMPlayer> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(BMPlayer::getUserId,userid);
        wrapper.eq(BMPlayer::getIsDeleted,0);
        return selectList(wrapper);
    }

    /**
     * 根据球队id 获取球员列表
     * @param teamId
     * @return
     */
    default List<BMPlayer> playerListByTeamId(Long teamId){
        LambdaQueryWrapper<BMPlayer> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(BMPlayer::getTeamId,teamId);
        wrapper.eq(BMPlayer::getIsDeleted,0);
        return selectList(wrapper);
    }

    List<CoachOrPlayerListReturnDTO> selectByPaymentStatus(@Param("param") CoachOrPlayerListDTO dto);

    default List<BMPlayer> selectByPhone(String phonenumber,Long teamId,List<Long> contestId){
        LambdaQueryWrapper<BMPlayer> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(BMPlayer::getPhone,phonenumber);
        wrapper.eq(Objects.nonNull(teamId),BMPlayer::getTeamId,teamId);
        wrapper.eq(BMPlayer::getIsDeleted,0);
        wrapper.in(CollUtil.isNotEmpty(contestId),BMPlayer::getContestId,contestId);
        return selectList(wrapper);
    }
}

